﻿
@{
    ViewBag.Title = "SignIn";
    Layout = "~/Views/_layouts/_LayoutMain.cshtml";
}
<script src="~/scripts/md5.js"></script>
<div style="padding:80px">
    <div class="layui-card">
        <div class="layui-card-header">登录</div>
        <div class="layui-card-body">
            <form class="layui-form layui-form-pane" action="Login" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="LoginID" lay-verify="required" placeholder="请输入账号" class="layui-input">
                    </div>
                    <div style="float: left; display: block;  padding: 9px 0!important;  line-height: 20px;  margin-right: 10px;color: #999!important;">使用注册填入的用户名或手机号登录</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="PassWords" lay-verify="required" placeholder="请输入密码" class="layui-input">
                    </div>
                </div>
                @*<div class="layui-form-item">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="ValidCode" lay-verify="required" placeholder="请输入验证码" class="layui-input">
                    </div>
                    <div class="layui-form-mid" style="padding: 0!important;">
                        <img class="fly-imagecode" src="ValidImage" />
                    </div>
                </div>*@
                <div class="layui-form-item">
                    <button class="layui-btn" lay-filter="formLogin" lay-submit="">立即登录</button>
                    <span style="padding-left:20px;"></span>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;
        //监听提交
        form.on('submit(formLogin)', function (data) {
            data.field.PassWords = hex_md5(data.field.PassWords);
            var index = layer.load();
            $.ajax({
                url: 'Login',
                type: 'POST',
                data: data.field,
                dataType: 'json',
                success: function (a, b) {
                    layer.close(index);
                    if (a.code == 0) {
                        window.location.href = 'Index';
                    }
                    else {
                        layer.msg(a.msg);
                        $('.fly-imagecode').src = 'ValidImage?t=' + new Date().getTime();
                    }
                },
                error: function (a, b, c) {
                    layer.close(index);
                    layer.msg(b);
                }
            })
            return false;
        });

        //刷新图形验证码
        //$('body').on('click', '.fly-imagecode', function () {
        //    this.src = 'ValidImage?t=' + new Date().getTime();
        //});
    });
</script>
